﻿using System;
using System.Collections.Generic;
using DynORM.Interfaces;
namespace DynORM.DAL.Interfaces
{
    //in order to add support of some new RDBMS just implement this interface for it (all other logic can be left untouched)
    public interface IDAL
    {
        string Enquote(string str);
        string Unquote(string str);
        bool TryConnect(string connectionString);
        string ChangeDBInConnectionString(string connectionString, string databaseName);
        string ChangeUserInConnectionString(string connectionString, string login, string password);
        void CreateDB(string connectionString, string dbName, params string[] auxData);
        void DropDB(string connectionString, string dbName, params string[] auxData);
        void AddColumn(string connectionString, string tableName, IFieldDescriptor fieldDesc);
        void AddForeignKeyConstraint(string connectionString, IForeignKeyDescriptor rd);
        void AddPrimaryKeyConstraint(string connectionString, IPrimaryKeyDescriptor pkd, bool createTable);
        void AddRow(string connectionString, IRow row);
        bool CheckTable(string connectionString, string tableName);
        void CreateTable(string connectionString, IRowDescriptor structure);
        bool DeleteRow(string connectionString, IPrimaryKey pk);
        bool DeleteRow(string connectionString, IRow row);
        void DropColumn(string connectionString, string tableName, IFieldDescriptor fieldDesc);
        void DropForeignKeyConstraint(string connectionString, IRelationDescriptor rd);
        void DropPrimaryKeyConstraint(string connectionString, IPrimaryKeyDescriptor pkd);
        void DropTable(string connectionString, string tableName);
        IEnumerable<string> GetAllTablesName(string connectionString);
        IEnumerable<IRowDescriptor> GetAllTablesStructure(string connectionString);
        IRow SelectRow(string connectionString, IPrimaryKey pk);
        IEnumerable<IRow> SelectRows(string connectionString, string tableName);
        IEnumerable<IRow> SelectRows(string connectionString, string tableName, IEnumerable<IORMComparison> predicate);
        IRowDescriptor SelectTableStructure(string connectionString, string tableName);
        bool TableContainsColumn(string connectionString, string tableName, string columnName, string columnType);
        bool TableContainsConstraint(string connectionString, string tableName, string constraintName, IEnumerable<IFieldDescriptor> fields);
        void UpdateRow(string connectionString, IRow row);
    }
}
